import { Mongo } from 'meteor/mongo';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';

import { Meteor } from 'meteor/meteor';

class LockPasswordsCollection extends Mongo.Collection {
    update(selector, modifier) {
        const result = super.update(selector, modifier);
        return result;
    }
    insert(family, callback) {
        const ourLockPasswords = family;
        const result = super.insert(ourLockPasswords, callback);
        return result;
    }
    remove(selector, callback) {
        const result = super.remove(selector, callback);
        return result;
    }
}

export const LockPasswords = new LockPasswordsCollection('lock_passwords');

LockPasswords.deny({
    insert() { return true; },
    update() { return true; },
    remove() { return true; },
});

LockPasswords.schema = new SimpleSchema({
    row: {
        label: '行数',
        type: Number,
    },
    password: {
        label: '密码',
        type: String,
        optional: true
    },
    pwd_valid_period: {
        label: '密码有效期',
        type: Date,
        optional: true
    },
    pwd_remain_times:{
        label: '密码剩余次数',
        type: Number,
        optional: true
    },
    deviceId: {
        label: '锁ＩＤ',
        type: String,
        optional: true
    },
    create_uid: {
        label: '用户ＩＤ',
        type: String,
    },
    create_uname: {
        label: '用户名',
        type: String,
    }
});
LockPasswords.attachSchema(LockPasswords.schema);
